home *** CD-ROM | disk | FTP | other *** search
- Path: news.lpr.carel.fi!usenet
- From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi>
- Newsgroups: comp.lang.c
- Subject: Re: Where Can I Find Standard C Library S
- Date: Thu, 08 Feb 1996 14:04:41 +0200
- Organization: Carelcomp Forest
- Message-ID: <3119E6D9.60FD@cmt.lpr.mail.carel.fi>
- References: <4fb8mf$ouo@spanky.pls.ov.com> <4fb90l$ouo@spanky.pls.ov.com>
- NNTP-Posting-Host: renoir.cclahti.carel.fi
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b6a (WinNT; I)
-
- Fletcher.Glenn@ov.com wrote:
- >
- >
- > Whoops! for strcpy:
- >
- > char *strcpy(char *destination, char *source)
- > {
- > char *retval;
- >
- > retval = destination;
- > while((*destination++ = *source++) != '\0');
- > return(retval);
- > }
- > Fletcher.Glenn@ov.com
-
- ... And you wonder why printf("%s\n", strcpy(tmp, "thingyam")); may not give correct
- results using your strcpy version... Try this for size:
-
- char *strcpy(char *destination, char *source)
- {
- char *retval = destination;
-
- do
- *destination = *source++;
- while (*destination++ != '\0');
- return retval;
- }
-
- This will also copy the nul-terminator. :)
-
- Later,
- AriL
- --
- All my opinions are mine and mine alone.
-